var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var proxy = require('http-proxy-middleware');
module.exports = {
  entry: {
    bundle: [path.resolve(__dirname, './src/main.js')],
    vendor: ['vue','vuex','vue-router']
  },
  output: {
    path: '/',
    publicPath: '/',
    filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.js*$/,
        loader: 'babel-loader',
        query: {compact: false},
        exclude: /^node_modules$/,
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: 'img/[name].[ext]'
        }
      }
    ]
  },
  plugins:[
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      filename: 'libs/vendor.js',
      minChunks: Infinity
    }),
    new HtmlWebpackPlugin({
        filename: './index.html',
        template: path.resolve(__dirname, './src/index.html'),
        //favicon:'./src/assets/img/favicon.ico',
        inject: true
    }),
    new webpack.HotModuleReplacementPlugin(),//开启热启动
    // new webpack.optimize.OccurrenceOrderPlugin(),
    // new webpack.NoErrorsPlugin(),
    // new webpack.NamedModulesPlugin(),
  ],
  resolve: {
    extensions: ['.js','.vue','.jsx'], //自动不全后缀
    alias: {
      //'vue$': 'vue/dist/vue.min.js',
      //'vue$': 'vue/dist/vue.js',//调试用开发版本，vue-devtool调试工具要用此版本，生产环境用 min
      'vuex$': 'vuex/dist/vuex.min.js',
      'vue-router$': 'vue-router/dist/vue-router.min.js'
    },

  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map',
  devServer:{
    contentBase: './dist',
    historyApiFallback: true
  }
}
